import 'package:flutter/material.dart';
import 'package:local_coffee/components/c_appbar/custom_appbar.dart';
import 'package:local_coffee/components/c_button/index.dart';
import 'package:local_coffee/components/c_dialog/custom_dialog.dart';

class ExampleCDialog extends StatefulWidget {
  
  ExampleCDialog({
    Key key
  }) : super(key: key);

  _ExampleDialogState createState() => _ExampleDialogState();
}

class _ExampleDialogState extends State<ExampleCDialog> {
  
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: customAppBar(
        title: 'CDialog 提示',
        context: context
      ),
      body: Column(
        children: <Widget>[
          Container(
            color: Colors.white,
            padding: EdgeInsets.symmetric(
              vertical: 10,
              horizontal: 15
            ),
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Container(
                  margin: EdgeInsets.only(bottom: 15),
                  child: Row(
                    children: <Widget>[
                      Container(
                        margin: EdgeInsets.only(right: 15),
                        child: CButton.normal(
                          child: Text('提示框'),
                          type: 'primary',
                          onPressed: () {
                            CDialog.alert(
                              context,
                              title: '提示标题',
                              content: '代码是写出来给人看的，附带能在机器上运行'
                            );
                          }
                        ),
                      ),
                      CButton.normal(
                        padding: EdgeInsets.symmetric(
                          horizontal: 15
                        ),
                        child: Text('提示框 [ 无标题 ]'),
                        type: 'primary',
                        onPressed: () {
                          CDialog.alert(
                            context,
                            content: '代码是写出来给人看的，附带能在机器上运行'
                          );
                        }
                      )
                    ],
                  ),
                ),
                Container(
                  padding: EdgeInsets.only(
                    bottom: 15
                  ),
                  child: Row(
                    children: <Widget>[
                      CButton.normal(
                        child: Text('确认弹窗'),
                        type: 'primary',
                        onPressed: () {
                          CDialog.confirm(
                            context, 
                            title: '确认提示框',
                            content: '一个完整的 flutter 实战 demo',
                            confirmButtonPress: () {
                              Navigator.pop(context);
                            }
                          );
                        }
                      )
                    ],
                  ),
                )
              ],
            ),
          )
        ],
      ),
    );
  }
}